﻿#region Using Statements
using DirectZZT.Shared.Screens;
using Microsoft.Xna.Framework;
using DirectZZT.Screens;
#endregion

namespace DirectZZT.Components
{
    /// <summary>
    /// Screen manager component.
    /// </summary>
    internal class ScreenManagerComponent : DrawableGameComponent
    {
        #region Fields

        private IScreenManager _screenManager;

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the XXX class.
        /// </summary>
        /// <param name="game"></param>
        public ScreenManagerComponent(Game game)
            : base(game)
        {
            _screenManager = new ScreenManager(game);
            _screenManager.PushScreen(new GameScreen(), true);
        }

        #endregion

        #region Methods

        /// <summary>
        /// Update
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            _screenManager.Update(gameTime);
        }

        /// <summary>
        /// Draw
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            _screenManager.Draw(gameTime);
        }

        /// <summary>
        /// Called when the screen manager shall be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            _screenManager.Dispose();
        }
        
        #endregion
    }
}
